package cn.briarbear.myblog.service.impl;

import cn.briarbear.myblog.entity.dto.AboutModifyForm;
import cn.briarbear.myblog.entity.table.About;
import cn.briarbear.myblog.service.IAboutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import cn.briarbear.myblog.repository.AboutRepository;

@CacheConfig(cacheNames = "about")
@Service
public class AboutServiceImpl implements IAboutService {

    @Autowired
    private AboutRepository aboutRepository;


    @Override
    public About getAbout() {
        return aboutRepository.findAboutById(1);  //返回第一个
    }

    @Override
    public void aboutModify(AboutModifyForm form) {
        About about = new About(form);
        about.setId(1);
        aboutRepository.save(about);
    }
}
